
import Mock from 'mockjs'

interface GoodsType {
  goodsId: string
  goodsName: string
  goodsImg: string
  goodsPrice: string
  goodsSale: string
}

// 内存模拟数据
const arr: GoodsType[] = []
for (let i = 0; i < 10; i++) {
  arr.push(Mock.mock({
    goodsId: '@id',
    goodsName: '@ctitle(30,10)',
    goodsImg: '@image("100x100", "#0282ff", "#FFF", "png", "占位图片")',
    goodsPrice: '@integer(100,500)',
    goodsSale: '@integer(10,100)'
  }))
}
export default [
  {
    url: '/list',
    method: 'get',
    response: () => {
      return arr
    }
  },
  {
    url: '/del',
    method: 'delete',
    response: ({query}) => {
      const index = arr.findIndex((item) => item.goodsId === query.goodsId)
      arr.splice(index, 1)
      return { success: true }
    }
  }
]
